<?php


class KnowledgeModel extends BaseModel
{
    protected $table = 'yf_knowledge';

    protected $principal = 'id';

    const status = [
        'open' => 1,//开启
        'close' => -1,//关闭
    ];

    public function findListBycategory(int $category_id, int $page, int $pagesiize) {
        return $this->findList([
            'status' => self::status['open'],
            'category_id' => $category_id
        ], [
            'id' , 'title' , 'brief' , 'category_id' , 'image'
        ] , $page, $pagesiize);
    }

    /**
     * 获取最新的几条数据
     * @param int $limit
     * @return array|bool
     */
    public function findNewList(int $limit)
    {
        return $this->db->select($this->table, ['id','title'], [
            'ORDER' => [
                'id' => 'DESC'
            ],
            'LIMIT' => $limit
        ]);
    }

}